package com.sky.service.impl;

import com.sky.entity.Category;
import com.sky.mapper.CategoryMapper;
import com.sky.result.Result;
import com.sky.service.UserCategoryService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCategoryServiceImpl implements UserCategoryService {
	
	private final CategoryMapper categoryMapper;
	
	public UserCategoryServiceImpl(CategoryMapper categoryMapper) {this.categoryMapper = categoryMapper;}
	
	@Override
	@Cacheable(cacheNames = "CategoryCache", key = "'List'")
	public Result categoryList(Integer type) {
		List<Category> categoryList = categoryMapper.getCategoryBy(null, type);
		return Result.success(categoryList);
	}
}
